


cd "/Users/eliemurard/Dropbox/WorldBank Refugee project/World Dev revision/replication/" 


use community_sportclub, clear 



******************************************************************************************
	* Table 3: Refugee resettlement and sport clubs
******************************************************************************************	
	
	xtile terc_pop1990 = POP1991_total, nq(3)
		
	g lowpop = inlist(terc_pop1990,1,2)
	label var  lowpop "low pop"
	
	g sh_refugees1928_tercpop = sh_refugees1928 *lowpop
	label var  sh_refugees1928_tercpop  "sh refugee 1928 * low pop"
	
	g sh_refugees1923_tercpop =  sh_refugees1923  *lowpop
	label var  sh_refugees1923_tercpop  "sh refugee 1923 * low pop"
	
	egen department_FE= group(department)

		

	
	global option varlabels tex plain fragment bdec(3) se starloc(1) starlevels(10 5 1) nocenter ///
		summstat(r2 \ N) summtitle( "$ R^2 $"\"Observations") summdec(3 0)  blankrows 

	*define controls for specification 	
	
	
	global mun_control   d2rail d2shr d2border ///
						elevation prcp_ann temp_ann score_suitability ///
						ln_dens_1920 city28 island

	global model_1  "Geography controls and 1991 Population","Yes"  \"Socio-Economic Development in 1991","" \ "Department FE",""
	global model_2  "Geography controls and 1991 Population","Yes"  \"Socio-Economic Development in 1991","Yes" \ "Department FE",""
	global model_3  "Geography controls and 1991 Population","Yes"  \"Socio-Economic Development in 1991","Yes" \ "Department FE","Yes"
			   
	global m1 $mun_control  i.terc_pop1990 lowpop 
	global m2 $m1 secondary1991 tertiary1991 emp_noagri1991 topoccu_cond1991 crafts_1991
	global m3 $m2 i.department_FE
	
	
	*define same sample for all specification 	
	qui reg  presence_asso $m3 
	cap drop samp
	g samp= e(sample)
	
	
	global T1  sh_refugees1928 	
	global T1_b  sh_refugees1928 sh_refugees1928_tercpop 
	
	global T2  sh_refugees1923  
	global T2_b  sh_refugees1923  sh_refugees1923_tercpop 

	global treat T1 T1_b
	

	
	
	

	tempvar outcome
	gen `outcome' = presence_asso  	
	local labout : variable label  `outcome'
	
	tempvar  samplee 
	g  `samplee' = samp  
	
	
	outreg, clear(base1)
	
	foreach typemodel in T1 T1_b  {
		
		global TREATkeep ${`typemodel'}  
		qui su `outcome'     if   `samplee'==1  
		local av: di %4.3f  r(mean)
		
		foreach k in 1 2 3 { 	
	
		dis " `labout' -  model `k' -  ${mods}" 
			qui  reg `outcome'  ${TREATkeep}  ${m`k'}   if   `samplee'==1 , vce(cluster department_FE)
			
				outreg,  merge(base1)  nod keep( ${TREATkeep} )   ///
						 pretext(  "\caption{`labout'}" "\begin{adjustbox}{max width=1.2  \textwidth,center}")  ///
						${option} ctitle("sample ${mods}", "(`k') " )   addrows("","" \  "${model_`k'}" \ "","" \ "Average outcome", `av'  \ "","") 
			
			}
			}			
		
	outreg, clear(base2)
	
	foreach typemodel in T2 T2_b  {
		
		global TREATkeep ${`typemodel'}  
		
		qui su `outcome'     if   `samplee'==1  
		local av: di %4.3f  r(mean)
	
	
		foreach k in 1 2 3 { 	
	
		dis " `labout' -  model `k' -  ${mods}" 
			qui  reg `outcome'  ${TREATkeep}  ${m`k'}   if   `samplee'==1 , vce(cluster department_FE)
			
				outreg,  merge(base2)  nod keep( ${TREATkeep} )   ///
						 pretext(  "\caption{`labout'}" "\begin{adjustbox}{max width=1.2  \textwidth,center}")  ///
						${option} ctitle("sample ${mods}", "(`k') " )  addrows("","" \  "${model_`k'}" \ "","" \ "Average outcome", `av' ) 
			
			}
			}			
		 
		outreg  , replace replay(base1) append(base2)  $option   
		

		
		
	
